using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.BLL;

public partial class crm_website_CampaignDataSearchDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            int labid = Int32.Parse(Request.Params["labid"].ToString());
            string begintime = Request.Params["begintime"].ToString();
            string endtime = Request.Params["endtime"].ToString();
            hflabid.Value = labid.ToString();
            hfbegintime.Value = begintime;
            hfendtime.Value = endtime;
            gview(labid, begintime, endtime); 
        }
    }

    protected void datalist_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

        GridView theGrid = sender as GridView;
        int newPageIndex = 0;

        if (-2 == e.NewPageIndex)
        {
            TextBox txtNewPageIndex = null;
            GridViewRow pagerRow = theGrid.BottomPagerRow;
            if (null != pagerRow)
            {
                txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
            }
            if (null != txtNewPageIndex)
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
            }
        }
        else
        {
            newPageIndex = e.NewPageIndex;
        }

        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
        theGrid.PageIndex = newPageIndex;
        gview(Int32.Parse(hflabid.Value), hfbegintime.Value, hfendtime.Value); 
    }

    void gview(int lab_id, string begintime, string endtime)
    {
        WebSiteDealBll wsdbll = new WebSiteDealBll();
        DataTable dt = wsdbll.getOBCampaignList(lab_id);
        if (dt.Rows.Count == 1)
        {
            gv_userlist.DataSource = wsdbll.getRegUserList(lab_id, begintime, endtime);
            gv_userlist.DataBind();
        }
    }
}
